<!DOCTYPE html>
<html>

<head>
    <title>发表新话题 - {$site_info.site_name|default=''}</title>
    <meta name="keywords" content="{$site_info.site_seo_keywords|default=''}" />
    <meta name="description" content="{$site_info.site_seo_description|default=''}">
    <include file="public@head" />
    <style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
    </style>
    <script type="text/html" id="photos-item-tpl">
        <li id="saved-image{id}">
            <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
            <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}" style="width: 200px;" title="图片名称">
            <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="imagePreviewDialog(this.src);">
            <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
            <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
        </li>
    </script>
</head>

<body class="bg-light">
    <include file="public@nav" />
    <section class="">
        <div class="card border-0">
            <div class="card-body p-2">
                <div class="media mb-3">
                    <div style="width: 42px;" class="mr-3">
                        <empty name="$user.avatar">
                            <img src="/assets/dist/images/default-thumbnail.png" class="img-fluid rounded-circle" alt="{$user.user_nickname}">
                            <else/>
                            <img src="{:cmf_get_user_avatar_url($user.avatar)}" class="img-fluid rounded-circle" alt="{$user.user_nickname}">
                        </empty>
                    </div>
                    <div class="media-body">
                        <p class="text-muted mb-1">
                            <empty name="$user.user_nickname">
                                {$user.user_login}
                                <else/> {$user.user_nickname}
                            </empty> 发布于 {:func_friendly_time(time())}
                        </p>
                        <h6 class="m-0">发表新话题</h6>
                    </div>
                </div>
                <div class="js-check-wrap">
                    <form action="{:url('portal/article/addPost')}" method="post" class="form-horizontal js-ajax-form">
                        <input class="form-control" type="hidden" name="post[post_keywords]" id="keywords" value="" placeholder="请输入关键字">
                        <div class="form-group">
                            <input class="form-control" type="text" name="post[post_title]" id="title" required value="" placeholder="请输入标题" />
                        </div>
                        <div class="form-group">
                            <select class="form-control" name="post[categories]" id="categories" required>
                                <option value=''>请选择分类</option>
                                {$category_tree|default=''}
                            </select>
                        </div>
                        <div class="form-group">
                            <script type="text/plain" id="content" name="post[post_content]"></script>
                            <span class="error-tips editor-warning">
                                        <i class="fa fa-warning"></i> 必填项
                                    </span>
                        </div>
                        <div class="form-group">
                            <th>帖子图片</th>
                            <ul id="photos" class="pic-list list-unstyled form-inline"></ul>
                            <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');" class="btn btn-warning btn-sm">选择图片</a>
                        </div>
                        <hr>
                        <div class="form-group mb-0">
                            <button type="submit" class="btn btn-info btn-block js-ajax-submit"> 立即发表 </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
    <!-- /container -->
    <include file="public@footer" />
    <include file="public@scripts" />
    <script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
    </script>
    <!-- <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.frontend.config.js"></script> -->
    <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript">
    //百度编辑器
    var ue = UE.getEditor('content', {
        toolbars: [
            ['bold', 'link', 'insertimage', 'insertvideo', 'indent', 'justifyleft', 'justifycenter', 'fontsize', 'fullscreen']
        ],
        fontsize: [16, 24],
        // 自定义的样式(icon等)
        //themePath: 'http://static.zcool.cn/git_z/z/ueditor143/themes/',
        initialFrameHeight: 400,
        retainOnlyLabelPasted: true,
        autoHeightEnabled: true,
        autoFloatEnabled: true,
        elementPathEnabled: false,
        zIndex: 2,
        maximumWords: 20000
    });
    ue.addListener("blur", function(type, event) {
        if (ue.hasContents()) {
            $('.editor-warning').hide();
        } else {
            $('.editor-warning').show();
        }
    });
    ue.addListener('beforeSelectionChange', function(editor) {
        console.log(editor);
        //submit('http://' + zMyDomain + '/draftArticle', 'http://' + zMyDomain + '/articles', $('.biz-draft-btn'));
    });
    </script>
</body>

</html>